export const flatternArray = (array) => {
  return array.reduce((map,item) => {
    map[item.id] = item
    return map;
  },{})
}

export const mapToArray = (map) => {
  return Object.keys(map).map( item => {
    return map[item];
  })
}

export const clicpFilePath = (url) => {
  const filePathArray = url.split('/');
  const length = filePathArray.length;
  const fileName = filePathArray[length - 1];
  const excludeExtensionFilename = fileName.slice(0, fileName.indexOf('.'));
  return excludeExtensionFilename
}

export const findParentNode = (node,parentNode) => {
  let current = node;
  while (current !== null) {
    console.log(current)
    if(!current.classList.contains(parentNode)) {
      current = node.parentNode
    } else {
      return current
    }
  }
  return false;
}